package com.evan.designpatterns.singleton.lazy;

/**
 * @author :liujiapeng01
 * @date :2019-03-13 11:13
 **/
public class DoubleCheckLazySingleton {

    private DoubleCheckLazySingleton() {
    }

    /**
     * 1.分配内存给这个对象
     * 2.初始化对象
     * 3.设置lazy指向刚分配的内存地址
     */
    private volatile static DoubleCheckLazySingleton doubleCheckLazySingleton = null;


    public static DoubleCheckLazySingleton getInstance() {
        if (doubleCheckLazySingleton == null) {
            synchronized (DoubleCheckLazySingleton.class) {
                if (doubleCheckLazySingleton == null) {
                    doubleCheckLazySingleton = new DoubleCheckLazySingleton();
                }
            }

        }
        return doubleCheckLazySingleton;
    }

}
